package com.belf.web.controller.console.group;

import com.belf.common.annotation.Log;
import com.belf.common.core.controller.BaseController;
import com.belf.common.core.domain.AjaxResult;
import com.belf.common.core.page.TableDataInfo;
import com.belf.common.enums.BusinessType;
import com.belf.common.utils.poi.ExcelUtil;
import com.belf.console.service.IDataReportInfoService;
import com.belf.console.domain.DataReportInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 迁移报告信息Controller
 * 
 * @author belf
 * @date 2024-08-21
 */
@RestController
@RequestMapping("/console/DataReportInfo")
public class DataReportInfoController extends BaseController
{
    @Autowired
    private IDataReportInfoService dataReportInfoService;

    /**
     * 查询迁移报告信息列表
     */
    @PreAuthorize("@ss.hasPermi('console:DataReportInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(DataReportInfo dataReportInfo)
    {
        startPage();
        List<DataReportInfo> list = dataReportInfoService.selectDataReportInfoList(dataReportInfo);
        return getDataTable(list);
    }

    /**
     * 导出迁移报告信息列表
     */
    @PreAuthorize("@ss.hasPermi('console:DataReportInfo:export')")
    @Log(title = "迁移报告信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataReportInfo dataReportInfo)
    {
        List<DataReportInfo> list = dataReportInfoService.selectDataReportInfoList(dataReportInfo);
        ExcelUtil<DataReportInfo> util = new ExcelUtil<DataReportInfo>(DataReportInfo.class);
        util.exportExcel(response, list, "迁移报告信息数据");
    }

    /**
     * 获取迁移报告信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('console:DataReportInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dataReportInfoService.selectDataReportInfoById(id));
    }

    /**
     * 新增迁移报告信息
     */
    @PreAuthorize("@ss.hasPermi('console:DataReportInfo:add')")
    @Log(title = "迁移报告信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataReportInfo dataReportInfo)
    {
        return toAjax(dataReportInfoService.insertDataReportInfo(dataReportInfo));
    }

    /**
     * 修改迁移报告信息
     */
    @PreAuthorize("@ss.hasPermi('console:DataReportInfo:edit')")
    @Log(title = "迁移报告信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataReportInfo dataReportInfo)
    {
        return toAjax(dataReportInfoService.updateDataReportInfo(dataReportInfo));
    }

    /**
     * 删除迁移报告信息
     */
    @PreAuthorize("@ss.hasPermi('console:DataReportInfo:remove')")
    @Log(title = "迁移报告信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dataReportInfoService.deleteDataReportInfoByIds(ids));
    }
}
